package com.crp.unitalinforbaseplat.app.core

import com.alibaba.fastjson.JSONException
import com.alibaba.fastjson.JSONObject
import com.crp.unitalinforbaseplat.app.unitalinforbaseplat.entity.BaseDomain

/**
 * @program: praduationppmsystem
 * @description:bool类型的Message
 * @author:  chenzhicai
 * @create: 2018-09-01-18-09
 **/
class BoolMessage(private var success: Boolean, message: String) : AbstractMessage() {
    private var message: String? = message
    private var record: BaseDomain? = null
    private var records: List<*>? = null

    fun getRecords(): List<*>? {
        return this.records
    }

    fun setRecords(records: List<*>) {
        this.records = records
    }

    fun getRecord(): BaseDomain? {
        return this.record
    }

    fun setRecord(record: BaseDomain) {
        this.record = record
    }

    fun BoolMessage() {}

    fun BoolMessage(json: JSONObject) {
        this.json = json
    }

    fun BoolMessage(success: Boolean, message: String) {
        this.success = success
        this.message = message
    }

    override fun buildJSON(): JSONObject {
        this.json = this.currentJson()

        try {
            this.json!!["message"] = this.message
            this.json!!["success"] = this.success
        } catch (var2: JSONException) {
            var2.printStackTrace()
        }

        return this.currentJson()
    }

    override fun putInJSON(record: JSONObject) {
        try {
            record["message"] = this.message
            record["success"] = this.success
        } catch (var3: JSONException) {
            var3.printStackTrace()
        }

    }

    fun putMessage(success: Boolean, message: String) {
        this.success = success
        this.message = message
    }

    fun isSuccess(): Boolean {
        return this.success
    }

    fun setSuccess(success: Boolean) {
        this.success = success
    }

    fun getMessage(): String? {
        return this.message
    }

    fun setMessage(message: String) {
        this.message = message
    }

    override fun equals(o: Any?): Boolean {
        if (this === o) {
            return true
        } else if (o != null && this.javaClass === o!!.javaClass) {
            val that = o as BoolMessage?
            return this.success == that!!.success
        } else {
            return false
        }
    }

    override fun hashCode(): Int {
        return if (this.success) 1 else 0
    }
}